package pdd.exceptions;

import com.alibaba.fastjson.annotation.JSONField;

/**
 * Created by gtx on 2018/6/11.
 * 拼多多顶级异常
 * @author gtx
 */
public class PddException extends Exception {

    /**
     * 异常码
     */
    @JSONField(name = "error_code")
    protected String errCode;
    /**
     * 异常信息
     */
    @JSONField(name = "error_msg")
    protected String errMsg;

    public PddException() {
    }

    public PddException(String message, Throwable cause) {
        super(message, cause);
    }

    public PddException(String message) {
        super(message);
    }

    public PddException(Throwable cause) {
        super(cause);
    }

    public PddException(String errCode, String errMsg) {
        super(errCode + ": " + errMsg);
        this.errCode = errCode;
        this.errMsg = errMsg;
    }

    public PddException(PddExceptionCodeEnum pddExceptionCodeEnum) {
        super(pddExceptionCodeEnum.getErrCode() + ": " + pddExceptionCodeEnum.getErrMsg());
        this.errCode = pddExceptionCodeEnum.getErrCode();
        this.errMsg = pddExceptionCodeEnum.getErrMsg();
    }

    public String getErrCode() {
        return errCode;
    }

    public void setErrCode(String errCode) {
        this.errCode = errCode;
    }

    public String getErrMsg() {
        return errMsg;
    }

    public void setErrMsg(String errMsg) {
        this.errMsg = errMsg;
    }

    @Override
    public String toString() {
        return "PddException{" +
                "errCode='" + errCode + '\'' +
                ", errMsg='" + errMsg + '\'' +
                '}';
    }
}
